package com.lecture.java8.reflex.fel;

import com.lecture.java8.reflex.reflections.UdFunctionHolder;
import com.greenpineyu.fel.FelEngine;
import com.greenpineyu.fel.FelEngineImpl;
import com.greenpineyu.fel.context.FelContext;
import com.greenpineyu.fel.function.CommonFunction;

import java.util.List;

/**
 * @author luyn
 * @version 1.0
 * @description
 * @date 2022/2/7 16:00
 */
public class FelDemo {
    public static void main(String[] args) {
        try {
            FelEngine felEngine = new FelEngineImpl();
            UdFunctionHolder udFunctionHolder = UdFunctionHolder.getInstance();
            List<CommonFunction> commonFunctionList = udFunctionHolder.getCommonFunctionList();
            for (CommonFunction commonFunction : commonFunctionList) {
                felEngine.addFun(commonFunction);
            }
            FelContext felContext = felEngine.getContext();
            Object eval = felEngine.eval("abs(12) > 10", felContext);
            System.out.println(eval);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
